From: Wei Liu Date: Mon, 27 Feb 2017 12:20:26 +0000 (+0000) Subject: libs/devicemodel: free xencall handle in error path in _open() X-Git-Tag: archive/raspbian/4.11.1-1+rpi1~1^2~66^2~2665 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=f68c7c618a3;p=xen.git libs/devicemodel: free xencall handle in error path in _open() Change the allocation to use calloc to get zeroed structure. Free xencall handler in error path. Spotted by Coverity. Signed-off-by: Wei Liu Reviewed-by: Paul Durrant Acked-by: Ian Jackson --- diff --git a/tools/libs/devicemodel/core.c b/tools/libs/devicemodel/core.c index 19ebef63b3..a85cb49c22 100644 --- a/tools/libs/devicemodel/core.c +++ b/tools/libs/devicemodel/core.c @@ -24,7 +24,7 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, unsigned open_flags) { - xendevicemodel_handle *dmod = malloc(sizeof(*dmod)); + xendevicemodel_handle *dmod = calloc(1, sizeof(*dmod)); int rc; if (!dmod) @@ -54,6 +54,7 @@ xendevicemodel_handle *xendevicemodel_open(xentoollog_logger *logger, err: xtl_logger_destroy(dmod->logger_tofree); + xencall_close(dmod->xcall); free(dmod); return NULL; }